package cn.bbs.ba.factory;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import cn.bbs.ba.base.Bean;
import cn.bbs.ba.path.BasePath;

public class BABeanFactory {

	private static final String _strPath = "application";
	private static ApplicationContext context = null;
	
	/**
	 * �õ�ָ��name��bean
	 * @param beanName ����
	 * @return Bean
	 */
	public static Bean getBean(String beanName) {
		if (context == null) {
			String path = BasePath.getPath(BABeanFactory._strPath);
			context = new FileSystemXmlApplicationContext(path + "/applicationContext-PAI.xml");
		}

		Bean fac = (Bean)context.getBean(beanName);
		return fac;
	}
}
